home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / src / logic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-13  |  17.4 KB  |  714 lines

  1. /* $Id: logic.c,v 1.4 1997/03/04 18:56:57 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.2
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: logic.c,v $
  26.  * Revision 1.4  1997/03/04 18:56:57  brianp
  27.  * added #include <stdlib.h> for abort()
  28.  *
  29.  * Revision 1.3  1997/01/28 22:16:31  brianp
  30.  * added gl_logicop_rgba_span() and gl_logicop_rgba_pixels()
  31.  *
  32.  * Revision 1.2  1997/01/04 00:13:11  brianp
  33.  * was using ! instead of ~ to invert pixel bits (ugh!)
  34.  *
  35.  * Revision 1.1  1996/09/13 01:38:16  brianp
  36.  * Initial revision
  37.  *
  38.  */
  39.  
  40.  
  41. #include <stdlib.h>
  42. #include "alphabuf.h"
  43. #include "context.h"
  44. #include "dlist.h"
  45. #include "logic.h"
  46. #include "macros.h"
  47. #include "pb.h"
  48. #include "span.h"
  49. #include "types.h"
  50.  
  51.  
  52.  
  53. void gl_LogicOp( GLcontext *ctx, GLenum opcode )
  54. {
  55.    if (INSIDE_BEGIN_END(ctx)) {
  56.       gl_error( ctx, GL_INVALID_OPERATION, "glLogicOp" );
  57.       return;
  58.    }
  59.    switch (opcode) {
  60.       case GL_CLEAR:
  61.       case GL_SET:
  62.       case GL_COPY:
  63.       case GL_COPY_INVERTED:
  64.       case GL_NOOP:
  65.       case GL_INVERT:
  66.       case GL_AND:
  67.       case GL_NAND:
  68.       case GL_OR:
  69.       case GL_NOR:
  70.       case GL_XOR:
  71.       case GL_EQUIV:
  72.       case GL_AND_REVERSE:
  73.       case GL_AND_INVERTED:
  74.       case GL_OR_REVERSE:
  75.       case GL_OR_INVERTED:
  76.          ctx->Color.LogicOp = opcode;
  77.          ctx->NewState |= NEW_RASTER_OPS;
  78.      return;
  79.       default:
  80.          gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
  81.      return;
  82.    }
  83. }
  84.  
  85.  
  86.  
  87.  
  88. /*
  89.  * Apply the current logic operator to a span of CI pixels.  This is only
  90.  * used if the device driver can't do logic ops.
  91.  */
  92. void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
  93.                          GLuint index[], GLubyte mask[] )
  94. {
  95.    GLuint dest[MAX_WIDTH];
  96.    GLuint i;
  97.  
  98.    /* Read dest values from frame buffer */
  99.    (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, dest );
  100.  
  101.    switch (ctx->Color.LogicOp) {
  102.       case GL_CLEAR:
  103.          for (i=0;i<n;i++) {
  104.         if (mask[i]) {
  105.            index[i] = 0;
  106.         }
  107.      }
  108.      break;
  109.       case GL_SET:
  110.          for (i=0;i<n;i++) {
  111.         if (mask[i]) {
  112.            index[i] = 1;
  113.         }
  114.      }
  115.      break;
  116.       case GL_COPY:
  117.      /* do nothing */
  118.      break;
  119.       case GL_COPY_INVERTED:
  120.          for (i=0;i<n;i++) {
  121.         if (mask[i]) {
  122.            index[i] = ~index[i];
  123.         }
  124.      }
  125.      break;
  126.       case GL_NOOP:
  127.          for (i=0;i<n;i++) {
  128.         if (mask[i]) {
  129.            index[i] = dest[i];
  130.         }
  131.      }
  132.      break;
  133.       case GL_INVERT:
  134.          for (i=0;i<n;i++) {
  135.         if (mask[i]) {
  136.            index[i] = ~dest[i];
  137.         }
  138.      }
  139.      break;
  140.       case GL_AND:
  141.          for (i=0;i<n;i++) {
  142.         if (mask[i]) {
  143.            index[i] &= dest[i];
  144.         }
  145.      }
  146.      break;
  147.       case GL_NAND:
  148.          for (i=0;i<n;i++) {
  149.         if (mask[i]) {
  150.            index[i] = ~(index[i] & dest[i]);
  151.         }
  152.      }
  153.      break;
  154.       case GL_OR:
  155.          for (i=0;i<n;i++) {
  156.         if (mask[i]) {
  157.            index[i] |= dest[i];
  158.         }
  159.      }
  160.      break;
  161.       case GL_NOR:
  162.          for (i=0;i<n;i++) {
  163.         if (mask[i]) {
  164.            index[i] = ~(index[i] | dest[i]);
  165.         }
  166.      }
  167.      break;
  168.       case GL_XOR:
  169.          for (i=0;i<n;i++) {
  170.         if (mask[i]) {
  171.            index[i] ^= dest[i];
  172.         }
  173.      }
  174.      break;
  175.       case GL_EQUIV:
  176.          for (i=0;i<n;i++) {
  177.         if (mask[i]) {
  178.            index[i] = ~(index[i] ^ dest[i]);
  179.         }
  180.      }
  181.      break;
  182.       case GL_AND_REVERSE:
  183.          for (i=0;i<n;i++) {
  184.         if (mask[i]) {
  185.            index[i] = index[i] & ~dest[i];
  186.         }
  187.      }
  188.      break;
  189.       case GL_AND_INVERTED:
  190.          for (i=0;i<n;i++) {
  191.         if (mask[i]) {
  192.            index[i] = ~index[i] & dest[i];
  193.         }
  194.      }
  195.      break;
  196.       case GL_OR_REVERSE:
  197.          for (i=0;i<n;i++) {
  198.         if (mask[i]) {
  199.            index[i] = index[i] | ~dest[i];
  200.         }
  201.      }
  202.      break;
  203.       case GL_OR_INVERTED:
  204.          for (i=0;i<n;i++) {
  205.         if (mask[i]) {
  206.            index[i] = ~index[i] | dest[i];
  207.         }
  208.      }
  209.      break;
  210.       default:
  211.      gl_error( ctx, GL_INVALID_ENUM, "gl_logic error" );
  212.    }
  213. }
  214.  
  215.  
  216.  
  217. /*
  218.  * Apply the current logic operator to an array of CI pixels.  This is only
  219.  * used if the device driver can't do logic ops.
  220.  */
  221. void gl_logicop_ci_pixels( GLcontext *ctx,
  222.                            GLuint n, const GLint x[], const GLint y[],
  223.                            GLuint index[], GLubyte mask[] )
  224. {
  225.    GLuint dest[PB_SIZE];
  226.    GLuint i;
  227.  
  228.    /* Read dest values from frame buffer */
  229.    (*ctx->Driver.ReadIndexPixels)( ctx, n, x, y, dest, mask );
  230.  
  231.    switch (ctx->Color.LogicOp) {
  232.       case GL_CLEAR:
  233.          for (i=0;i<n;i++) {
  234.         if (mask[i]) {
  235.            index[i] = 0;
  236.         }
  237.      }
  238.      break;
  239.       case GL_SET:
  240.          for (i=0;i<n;i++) {
  241.         if (mask[i]) {
  242.            index[i] = 1;
  243.         }
  244.      }
  245.      break;
  246.       case GL_COPY:
  247.      /* do nothing */
  248.      break;
  249.       case GL_COPY_INVERTED:
  250.          for (i=0;i<n;i++) {
  251.         if (mask[i]) {
  252.            index[i] = ~index[i];
  253.         }
  254.      }
  255.      break;
  256.       case GL_NOOP:
  257.          for (i=0;i<n;i++) {
  258.         if (mask[i]) {
  259.            index[i] = dest[i];
  260.         }
  261.      }
  262.      break;
  263.       case GL_INVERT:
  264.          for (i=0;i<n;i++) {
  265.         if (mask[i]) {
  266.            index[i] = ~dest[i];
  267.         }
  268.      }
  269.      break;
  270.       case GL_AND:
  271.          for (i=0;i<n;i++) {
  272.         if (mask[i]) {
  273.            index[i] &= dest[i];
  274.         }
  275.      }
  276.      break;
  277.       case GL_NAND:
  278.          for (i=0;i<n;i++) {
  279.         if (mask[i]) {
  280.            index[i] = ~(index[i] & dest[i]);
  281.         }
  282.      }
  283.      break;
  284.       case GL_OR:
  285.          for (i=0;i<n;i++) {
  286.         if (mask[i]) {
  287.            index[i] |= dest[i];
  288.         }
  289.      }
  290.      break;
  291.       case GL_NOR:
  292.          for (i=0;i<n;i++) {
  293.         if (mask[i]) {
  294.            index[i] = ~(index[i] | dest[i]);
  295.         }
  296.      }
  297.      break;
  298.       case GL_XOR:
  299.          for (i=0;i<n;i++) {
  300.         if (mask[i]) {
  301.            index[i] ^= dest[i];
  302.         }
  303.      }
  304.      break;
  305.       case GL_EQUIV:
  306.          for (i=0;i<n;i++) {
  307.         if (mask[i]) {
  308.            index[i] = ~(index[i] ^ dest[i]);
  309.         }
  310.      }
  311.      break;
  312.       case GL_AND_REVERSE:
  313.          for (i=0;i<n;i++) {
  314.         if (mask[i]) {
  315.            index[i] = index[i] & ~dest[i];
  316.         }
  317.      }
  318.      break;
  319.       case GL_AND_INVERTED:
  320.          for (i=0;i<n;i++) {
  321.         if (mask[i]) {
  322.            index[i] = ~index[i] & dest[i];
  323.         }
  324.      }
  325.      break;
  326.       case GL_OR_REVERSE:
  327.          for (i=0;i<n;i++) {
  328.         if (mask[i]) {
  329.            index[i] = index[i] | ~dest[i];
  330.         }
  331.      }
  332.      break;
  333.       case GL_OR_INVERTED:
  334.          for (i=0;i<n;i++) {
  335.         if (mask[i]) {
  336.            index[i] = ~index[i] | dest[i];
  337.         }
  338.      }
  339.      break;
  340.       default:
  341.      gl_error( ctx, GL_INVALID_ENUM, "gl_logic_pixels error" );
  342.    }
  343. }
  344.  
  345.  
  346.  
  347. /*
  348.  * Apply the current logic operator to a span of RGBA pixels.  This is only
  349.  * used if the device driver can't do logic ops.
  350.  */
  351. void gl_logicop_rgba_span( GLcontext *ctx,
  352.                            GLuint n, GLint x, GLint y,
  353.                            GLubyte red[], GLubyte green[],
  354.                            GLubyte blue[], GLubyte alpha[],
  355.                            GLubyte mask[] )
  356. {
  357.    GLubyte rdest[MAX_WIDTH], gdest[MAX_WIDTH];
  358.    GLubyte bdest[MAX_WIDTH], adest[MAX_WIDTH];
  359.    GLuint i;
  360.  
  361.    /* Read span of current frame buffer pixels */
  362.    gl_read_color_span( ctx, n, x, y, rdest, gdest, bdest, adest );
  363.  
  364.    /* apply logic op */
  365.    switch (ctx->Color.LogicOp) {
  366.       case GL_CLEAR:
  367.          for (i=0;i<n;i++) {
  368.             if (mask[i]) {
  369.                red[i] = green[i] = blue[i] = alpha[i] = 0;
  370.             }
  371.          }
  372.          break;
  373.       case GL_SET:
  374.          {
  375.             GLubyte r = (GLint) ctx->Visual->RedScale;
  376.             GLubyte g = (GLint) ctx->Visual->GreenScale;
  377.             GLubyte b = (GLint) ctx->Visual->BlueScale;
  378.             GLubyte a = (GLint) ctx->Visual->AlphaScale;
  379.             for (i=0;i<n;i++) {
  380.                if (mask[i]) {
  381.                   red[i]   = r;
  382.                   green[i] = g;
  383.                   blue[i]  = b;
  384.                   alpha[i] = a;
  385.                }
  386.             }
  387.          }
  388.          break;
  389.       case GL_COPY:
  390.          /* do nothing */
  391.          break;
  392.       case GL_COPY_INVERTED:
  393.          for (i=0;i<n;i++) {
  394.             if (mask[i]) {
  395.                red[i]   = ~red[i];
  396.                green[i] = ~green[i];
  397.                blue[i]  = ~blue[i];
  398.                alpha[i] = ~alpha[i];
  399.             }
  400.          }
  401.          break;
  402.       case GL_NOOP:
  403.          for (i=0;i<n;i++) {
  404.             if (mask[i]) {
  405.                red[i]   = rdest[i];
  406.                green[i] = gdest[i];
  407.                blue[i]  = bdest[i];
  408.                alpha[i] = adest[i];
  409.             }
  410.          }
  411.          break;
  412.       case GL_INVERT:
  413.          for (i=0;i<n;i++) {
  414.             if (mask[i]) {
  415.                red[i]   = ~rdest[i];
  416.                green[i] = ~gdest[i];
  417.                blue[i]  = ~bdest[i];
  418.                alpha[i] = ~adest[i];
  419.             }
  420.          }
  421.          break;
  422.       case GL_AND:
  423.          for (i=0;i<n;i++) {
  424.             if (mask[i]) {
  425.                red[i]   &= rdest[i];
  426.                green[i] &= gdest[i];
  427.                blue[i]  &= bdest[i];
  428.                alpha[i] &= adest[i];
  429.             }
  430.          }
  431.          break;
  432.       case GL_NAND:
  433.          for (i=0;i<n;i++) {
  434.             if (mask[i]) {
  435.                red[i]   = ~(red[i]   & rdest[i]);
  436.                green[i] = ~(green[i] & gdest[i]);
  437.                blue[i]  = ~(blue[i]  & bdest[i]);
  438.                alpha[i] = ~(alpha[i] & adest[i]);
  439.             }
  440.          }
  441.          break;
  442.       case GL_OR:
  443.          for (i=0;i<n;i++) {
  444.             if (mask[i]) {
  445.                red[i]   |= rdest[i];
  446.                green[i] |= gdest[i];
  447.                blue[i]  |= bdest[i];
  448.                alpha[i] |= adest[i];
  449.             }
  450.          }
  451.          break;
  452.       case GL_NOR:
  453.          for (i=0;i<n;i++) {
  454.             if (mask[i]) {
  455.                red[i]   = ~(red[i]   | rdest[i]);
  456.                green[i] = ~(green[i] | gdest[i]);
  457.                blue[i]  = ~(blue[i]  | bdest[i]);
  458.                alpha[i] = ~(alpha[i] | adest[i]);
  459.             }
  460.          }
  461.          break;
  462.       case GL_XOR:
  463.          for (i=0;i<n;i++) {
  464.             if (mask[i]) {
  465.                red[i]   ^= rdest[i];
  466.                green[i] ^= gdest[i];
  467.                blue[i]  ^= bdest[i];
  468.                alpha[i] ^= adest[i];
  469.             }
  470.          }
  471.          break;
  472.       case GL_EQUIV:
  473.          for (i=0;i<n;i++) {
  474.             if (mask[i]) {
  475.                red[i]   = ~(red[i]   ^ rdest[i]);
  476.                green[i] = ~(green[i] ^ gdest[i]);
  477.                blue[i]  = ~(blue[i]  ^ bdest[i]);
  478.                alpha[i] = ~(alpha[i] ^ adest[i]);
  479.             }
  480.          }
  481.          break;
  482.       case GL_AND_REVERSE:
  483.          for (i=0;i<n;i++) {
  484.             if (mask[i]) {
  485.                red[i]   = red[i]   & ~rdest[i];
  486.                green[i] = green[i] & ~gdest[i];
  487.                blue[i]  = blue[i]  & ~bdest[i];
  488.                alpha[i] = alpha[i] & ~adest[i];
  489.             }
  490.          }
  491.          break;
  492.       case GL_AND_INVERTED:
  493.          for (i=0;i<n;i++) {
  494.             if (mask[i]) {
  495.                red[i]   = ~red[i]   & rdest[i];
  496.                green[i] = ~green[i] & gdest[i];
  497.                blue[i]  = ~blue[i]  & bdest[i];
  498.                alpha[i] = ~alpha[i] & adest[i];
  499.             }
  500.          }
  501.          break;
  502.       case GL_OR_REVERSE:
  503.          for (i=0;i<n;i++) {
  504.             if (mask[i]) {
  505.                red[i]   = red[i]   | ~rdest[i];
  506.                green[i] = green[i] | ~gdest[i];
  507.                blue[i]  = blue[i]  | ~bdest[i];
  508.                alpha[i] = alpha[i] | ~adest[i];
  509.             }
  510.          }
  511.          break;
  512.       case GL_OR_INVERTED:
  513.          for (i=0;i<n;i++) {
  514.             if (mask[i]) {
  515.                red[i]   = ~red[i]   | rdest[i];
  516.                green[i] = ~green[i] | gdest[i];
  517.                blue[i]  = ~blue[i]  | bdest[i];
  518.                alpha[i] = ~alpha[i] | adest[i];
  519.             }
  520.          }
  521.          break;
  522.       default:
  523.          /* should never happen */
  524.          abort();
  525.    }
  526. }
  527.  
  528.  
  529.  
  530. /*
  531.  * Apply the current logic operator to an array of RGBA pixels.  This is only
  532.  * used if the device driver can't do logic ops.
  533.  */
  534. void gl_logicop_rgba_pixels( GLcontext *ctx,
  535.                              GLuint n, const GLint x[], const GLint y[],
  536.                              GLubyte red[], GLubyte green[],
  537.                              GLubyte blue[], GLubyte alpha[],
  538.                              GLubyte mask[] )
  539. {
  540.    GLubyte rdest[PB_SIZE], gdest[PB_SIZE], bdest[PB_SIZE], adest[PB_SIZE];
  541.    GLuint i;
  542.  
  543.    /* Read pixels from current color buffer */
  544.    (*ctx->Driver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask );
  545.    if (ctx->RasterMask & ALPHABUF_BIT) {
  546.       gl_read_alpha_pixels( ctx, n, x, y, adest, mask );
  547.    }
  548.  
  549.    /* apply logic op */
  550.    switch (ctx->Color.LogicOp) {
  551.       case GL_CLEAR:
  552.          for (i=0;i<n;i++) {
  553.             if (mask[i]) {
  554.                red[i] = green[i] = blue[i] = alpha[i] = 0;
  555.             }
  556.          }
  557.          break;
  558.       case GL_SET:
  559.          {
  560.             GLubyte r = (GLint) ctx->Visual->RedScale;
  561.             GLubyte g = (GLint) ctx->Visual->GreenScale;
  562.             GLubyte b = (GLint) ctx->Visual->BlueScale;
  563.             GLubyte a = (GLint) ctx->Visual->AlphaScale;
  564.             for (i=0;i<n;i++) {
  565.                if (mask[i]) {
  566.                   red[i]   = r;
  567.                   green[i] = g;
  568.                   blue[i]  = b;
  569.                   alpha[i] = a;
  570.                }
  571.             }
  572.          }
  573.          break;
  574.       case GL_COPY:
  575.          /* do nothing */
  576.          break;
  577.       case GL_COPY_INVERTED:
  578.          for (i=0;i<n;i++) {
  579.             if (mask[i]) {
  580.                red[i]   = ~red[i];
  581.                green[i] = ~green[i];
  582.                blue[i]  = ~blue[i];
  583.                alpha[i] = ~alpha[i];
  584.             }
  585.          }
  586.          break;
  587.       case GL_NOOP:
  588.          for (i=0;i<n;i++) {
  589.             if (mask[i]) {
  590.                red[i]   = rdest[i];
  591.                green[i] = gdest[i];
  592.                blue[i]  = bdest[i];
  593.                alpha[i] = adest[i];
  594.             }
  595.          }
  596.          break;
  597.       case GL_INVERT:
  598.          for (i=0;i<n;i++) {
  599.             if (mask[i]) {
  600.                red[i]   = ~rdest[i];
  601.                green[i] = ~gdest[i];
  602.                blue[i]  = ~bdest[i];
  603.                alpha[i] = ~adest[i];
  604.             }
  605.          }
  606.          break;
  607.       case GL_AND:
  608.          for (i=0;i<n;i++) {
  609.             if (mask[i]) {
  610.                red[i]   &= rdest[i];
  611.                green[i] &= gdest[i];
  612.                blue[i]  &= bdest[i];
  613.                alpha[i] &= adest[i];
  614.             }
  615.          }
  616.          break;
  617.       case GL_NAND:
  618.          for (i=0;i<n;i++) {
  619.             if (mask[i]) {
  620.                red[i]   = ~(red[i]   & rdest[i]);
  621.                green[i] = ~(green[i] & gdest[i]);
  622.                blue[i]  = ~(blue[i]  & bdest[i]);
  623.                alpha[i] = ~(alpha[i] & adest[i]);
  624.             }
  625.          }
  626.          break;
  627.       case GL_OR:
  628.          for (i=0;i<n;i++) {
  629.             if (mask[i]) {
  630.                red[i]   |= rdest[i];
  631.                green[i] |= gdest[i];
  632.                blue[i]  |= bdest[i];
  633.                alpha[i] |= adest[i];
  634.             }
  635.          }
  636.          break;
  637.       case GL_NOR:
  638.          for (i=0;i<n;i++) {
  639.             if (mask[i]) {
  640.                red[i]   = ~(red[i]   | rdest[i]);
  641.                green[i] = ~(green[i] | gdest[i]);
  642.                blue[i]  = ~(blue[i]  | bdest[i]);
  643.                alpha[i] = ~(alpha[i] | adest[i]);
  644.             }
  645.          }
  646.          break;
  647.       case GL_XOR:
  648.          for (i=0;i<n;i++) {
  649.             if (mask[i]) {
  650.                red[i]   ^= rdest[i];
  651.                green[i] ^= gdest[i];
  652.                blue[i]  ^= bdest[i];
  653.                alpha[i] ^= adest[i];
  654.             }
  655.          }
  656.          break;
  657.       case GL_EQUIV:
  658.          for (i=0;i<n;i++) {
  659.             if (mask[i]) {
  660.                red[i]   = ~(red[i]   ^ rdest[i]);
  661.                green[i] = ~(green[i] ^ gdest[i]);
  662.                blue[i]  = ~(blue[i]  ^ bdest[i]);
  663.                alpha[i] = ~(alpha[i] ^ adest[i]);
  664.             }
  665.          }
  666.          break;
  667.       case GL_AND_REVERSE:
  668.          for (i=0;i<n;i++) {
  669.             if (mask[i]) {
  670.                red[i]   = red[i]   & ~rdest[i];
  671.                green[i] = green[i] & ~gdest[i];
  672.                blue[i]  = blue[i]  & ~bdest[i];
  673.                alpha[i] = alpha[i] & ~adest[i];
  674.             }
  675.          }
  676.          break;
  677.       case GL_AND_INVERTED:
  678.          for (i=0;i<n;i++) {
  679.             if (mask[i]) {
  680.                red[i]   = ~red[i]   & rdest[i];
  681.                green[i] = ~green[i] & gdest[i];
  682.                blue[i]  = ~blue[i]  & bdest[i];
  683.                alpha[i] = ~alpha[i] & adest[i];
  684.             }
  685.          }
  686.          break;
  687.       case GL_OR_REVERSE:
  688.          for (i=0;i<n;i++) {
  689.             if (mask[i]) {
  690.                red[i]   = red[i]   | ~rdest[i];
  691.                green[i] = green[i] | ~gdest[i];
  692.                blue[i]  = blue[i]  | ~bdest[i];
  693.                alpha[i] = alpha[i] | ~adest[i];
  694.             }
  695.          }
  696.          break;
  697.       case GL_OR_INVERTED:
  698.          for (i=0;i<n;i++) {
  699.             if (mask[i]) {
  700.                red[i]   = ~red[i]   | rdest[i];
  701.                green[i] = ~green[i] | gdest[i];
  702.                blue[i]  = ~blue[i]  | bdest[i];
  703.                alpha[i] = ~alpha[i] | adest[i];
  704.             }
  705.          }
  706.          break;
  707.       default:
  708.          /* should never happen */
  709.          abort();
  710.    }
  711. }
  712.  
  713.  
  714.